<template>
    <el-dialog v-if="dialogVisible" :close-on-click-modal='false' :title="titleText()" :visible.sync="dialogVisible" @close="resetForm('addForm')" width="400px">
        <span class="font_14 color_01">链接</span>
        <div class="flexbox flexcenter link_box">
            <div class="link_text flex">{{linkForm.url}}</div>
            <div class="link_btn" @click="copy(linkForm.url)">复制</div>
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button size="small" type="primary" @click="dialogVisible = false" class="el-button-width">关 闭</el-button>
        </span>
    </el-dialog>
</template>

<script>
export default {
    name: "",
    data() {
        return {
            loading: false,
            dialogVisible: false,
            linkForm: {
                type: null,
                url: "",
            },
        };
    },
    created() {},
    methods: {
        titleText() {
            let text = null;
            if (this.linkForm.type == "ba") {
                text = "推广位备案";
            } else if (this.linkForm.type == "sp") {
                text = "商品goodsSign";
            } else if (this.linkForm.type == "lj") {
                text = "推广链接";
            }
            return text;
        },

        // 复制
        copy(text) {
            let url = text;
            let oInput = document.createElement("input");
            oInput.value = url;
            document.body.appendChild(oInput);
            oInput.select(); // 选择对象;
            document.execCommand("Copy"); // 执行浏览器复制命令
            this.$message({
                message: "复制成功",
                type: "success",
            });
            oInput.remove();
        },
    },
    components: {},
};
</script>


<style scoped>
.link_box {
    margin-top: 12px;
}
.link_btn,
.link_text {
    height: 36px;
    line-height: 36px;
    background: rgba(165, 177, 209, 0.08);
    border-radius: 2px;
    padding: 0 12px;
    font-size: 14px;
    color: #17233d;
}
.link_text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.link_btn {
    flex-shrink: 0;
    margin-left: 12px;
    cursor: pointer;
}
</style>
